package com.magnificent.atlantis.common.entity.messages;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * User: Babanin
 * Date: 26.03.2009
 * Time: 12:24:16
 */

@Entity()
@Table(name = "message_text")
public class ServerTextMessage extends ServerMessage implements Serializable {
    private String title;
    private String message;
    protected Date date;

    public ServerTextMessage() {
    }

    @Basic()
    @Column(name = "title")
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic()
    @Column(name = "message")
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ServerTextMessage)) return false;

        ServerTextMessage message1 = (ServerTextMessage) o;

        if (userFromId != message1.userFromId) return false;
        if (userToId != message1.userToId) return false;
        if (message != null ? !message.equals(message1.message) : message1.message != null) return false;
        if (sentDate != null ? !sentDate.equals(message1.sentDate) : message1.sentDate != null) return false;
        if (title != null ? !title.equals(message1.title) : message1.title != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = title != null ? title.hashCode() : 0;
        result = 31 * result + (message != null ? message.hashCode() : 0);
        result = 31 * result + (sentDate != null ? sentDate.hashCode() : 0);
        result = 31 * result + userToId;
        result = 31 * result + userFromId;
        return result;
    }
}
